package wqas

import (
	"net/http"

	"lxb.com/bot_mock/webserver/server/bot"
)

// cobot 后端 mock

func ConfigHttpHandler() {

	statistics := NewStatisticsHandler()
	http.Handle("/api/statistics/statistics", http.HandlerFunc(statistics.GetStatistics))
	http.Handle("/api/statistics/passRate", http.HandlerFunc(statistics.GetPassRate))
	http.Handle("/api/statistics/defect", http.HandlerFunc(statistics.GetDefect))

	analysis := NewAnalysisHandler()

	http.Handle("/api/analysis/ui", http.HandlerFunc(analysis.GetUIAnalysis))
	http.Handle("/api/analysis/defectCause", http.HandlerFunc(analysis.GetDefectCause))

	improvement := NewImprovementHandler()
	http.Handle("/improvement/statistics", http.HandlerFunc(improvement.GetStatistics))
	http.Handle("/improvement/dailyReport", http.HandlerFunc(improvement.GetDailyReport))
	http.Handle("/improvement/batchReport", http.HandlerFunc(improvement.GetBatchReport))
	http.Handle("/improvement/record", http.HandlerFunc(improvement.GetImprovementRecord))

	http.Handle("/improvement/createDailyReport", http.HandlerFunc(improvement.GenerateDailyReport))
	http.Handle("/improvement/createBatchReport", http.HandlerFunc(improvement.GenerateBatchReport))
	http.Handle("/improvement/pushDailyReport", http.HandlerFunc(improvement.PushDailyReport))
	http.Handle("/improvement/pushBatchReport", http.HandlerFunc(improvement.PushBatchReport))
}

func ConfigHttpHandlerWithMux(mux *http.ServeMux) {

	statistics := NewStatisticsHandler()
	mux.Handle("/statistics/statistics", http.HandlerFunc(statistics.GetStatistics))
	mux.Handle("/statistics/passRate", http.HandlerFunc(statistics.GetPassRate))
	mux.Handle("/statistics/defect", http.HandlerFunc(statistics.GetDefect))

	analysis := NewAnalysisHandler()

	mux.Handle("/analysis/ui", http.HandlerFunc(analysis.GetUIAnalysis))
	mux.Handle("/analysis/defectCause", http.HandlerFunc(analysis.GetDefectCause))

	improvement := NewImprovementHandler()
	mux.Handle("/improvement/statistics", http.HandlerFunc(improvement.GetStatistics))
	mux.Handle("/improvement/dailyReport", http.HandlerFunc(improvement.GetDailyReport))
	mux.Handle("/improvement/batchReport", http.HandlerFunc(improvement.GetBatchReport))
	mux.Handle("/improvement/record", http.HandlerFunc(improvement.GetImprovementRecord))
	mux.Handle("/improvement/getDailyStatistics", http.HandlerFunc(improvement.GetDailyStatistics))
	mux.Handle("/improvement/getDailyDetailByDefect", http.HandlerFunc(improvement.GetDailyDetailByDefect))

	mux.Handle("/improvement/createDailyReport", http.HandlerFunc(improvement.GenerateDailyReport))
	mux.Handle("/improvement/createBatchReport", http.HandlerFunc(improvement.GenerateBatchReport))
	mux.Handle("/improvement/pushDailyReport", http.HandlerFunc(improvement.PushDailyReport))
	mux.Handle("/improvement/pushBatchReport", http.HandlerFunc(improvement.PushBatchReport))

	fileHandler := bot.NewFileHandler()
	mux.Handle("/file/browser", http.HandlerFunc(fileHandler.Download))

}
